let pomelo = require("pomelo");

module.exports = function (app) {
    return function () {
        initialize(app);
    };
};

function initialize(app) {
    app.set('connectorConfig', {
        connector: pomelo.connectors.hybridconnector,
        heartbeat: 100,
        useDict: true,
        useProtobuf: true,
        handshake: function (msg, cb) {
            cb(null, msg.user);
        }
    });

    app.set("sessionConfig", {
        sendDirectly: true
    });

    app.set('proxyConfig', {
        retryTimes: -1
    });

    app.event.on(pomelo.events.CLOSE_SESSION, function (session) {
        app.rpc.account.loginRemote.logout(session, session.frontendId, session.id, function (error) {
        });
    });
}